using CampusModel.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CampusModel.Configuration;

public class ClassConfiguration: IEntityTypeConfiguration<Class>
{

    public void Configure(EntityTypeBuilder<Class> builder)
    {
        builder.HasKey(c => c.Id);
        builder.HasMany(x=>x.Courses).WithOne(x=>x.Class).HasForeignKey(x=>x.ClassId);
        builder.HasMany(x=>x.Students).WithOne(x=>x.Class).HasForeignKey(x=>x.ClassId).OnDelete(DeleteBehavior.NoAction);
    }
}